from pydantic import BaseModel, ValidationError, constr, Field
from typing import Optional
from common import ai

# BaseModel是flask pydantic包提供的一个基础类，ParamOutline是这个BaseModel的继承类
# 继承Pydantic的好处在于 Pydantic可以很容易的处理  数据验证，序列化，数据格式转换如dictionary-json等操作。


class ParamThesisId(BaseModel):
    userId: Optional[int] = -1
    thesisId: Optional[int] = -1
    model: Optional[str] = ai.MODEL_GPT35


class ParamGenerateOutline(BaseModel):
    userId: Optional[int] = -1
    thesisId: Optional[int] = -1
    paragraphId: Optional[int] = -1
    length: Optional[int] = 500
    instruction: Optional[str] = ""
    model: Optional[str] = ai.MODEL_GPT35


class SaveNewPara(BaseModel):
    userId: Optional[int] = -1
    thesisId: Optional[int] = -1
    baseParaId: Optional[str] = ""
    addType: Optional[str] = "next"
    newTitle: Optional[str] = ""
    newContent: Optional[str] = ""


class MovePara(BaseModel):
    userId: Optional[int] = -1
    thesisId: Optional[int] = -1
    paraId: Optional[str] = ""
    moveType: Optional[str] = "up"


class DeleteParagraph(BaseModel):
    userId: Optional[int] = -1
    thesisId: Optional[int] = -1
    paraId: Optional[str] = ""


class ParamSaveSingleParagraph(BaseModel):
    userId: Optional[int] = -1
    thesisId: Optional[int] = -1
    paragraphId: Optional[str] = -1
    title: Optional[str] = ""
    text: Optional[str] = ""


class ParamSaveDigest(BaseModel):
    userId: Optional[int] = -1
    thesisId: Optional[int] = -1
    digest: Optional[str] = ""
    digestEn: Optional[str] = ""
    keywords: Optional[str] = ""
    keywordsEn: Optional[str] = ""


class SaveThesisProperty(BaseModel):
    userId: Optional[int] = -1
    propName: str = "thanks"
    thesisId: Optional[int] = -1
    content: Optional[str] = ""
